package com.woniuxy.api.fallback;

import com.woniuxy.api.RemoteProductServer;
import com.woniuxy.entity.Product;
import com.woniuxy.entity.utils.ResponseEntity;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author: 马宇航
 * @Description: 降级工厂
 * @DateTime: 22/10/12/0012 12:07
 * @Component: 成都蜗牛学苑
 **/
@Component
public class FallBackFactoryComponent implements FallbackFactory<RemoteProductServer> {
    @Override
    public RemoteProductServer create(Throwable throwable) {
        return new RemoteProductServer() {
            @Override
            public ResponseEntity findById(Integer pid) {
                return ResponseEntity.TIME_OUT;
            }

            @Override
            public ResponseEntity updateOne(Product product) {
                return ResponseEntity.TIME_OUT;
            }

            @Override
            public ResponseEntity searchPrice(Double floorPrice, Double ceilingPrice) {
                return ResponseEntity.TIME_OUT;
            }

            @Override
            public ResponseEntity searchPrice(Map map) {
                return ResponseEntity.TIME_OUT;
            }

            @Override
            public ResponseEntity searchPrice(Product product) {
                return ResponseEntity.TIME_OUT;
            }
        };
    }
}
